// 引入创建路由器组件
import { createRouter, createWebHistory } from "vue-router";
import Home from "@/views/Home.vue";
import News from "@/views/News.vue";
import About from "@/views/About.vue";
import NewsDetail from "@/views/NewsDetail.vue";
// 创建路由
const router = createRouter({
  // 路由器的工作模式
  history: createWebHistory(),
  routes: [
    {
      // 路由的命名
      name: "shouye",
      path: "/",
      component: Home,
    },
    {
      name: "xinwen",
      path: "/news",
      component: News,
      children: [
        {
          // 路由的命名
          name: "newsDetail",
          // 使用占位符
          path: "detail/:id/:title/:content",
          component: NewsDetail,
        },
      ],
    },
    {
      name: "guanyu",
      path: "/about",
      component: About,
    },
  ],
});

export default router;
